#include <stdlib.h>
#include <stdio.h>

#include "mysql.h"

void finish_with_error(MYSQL *con)
{
  fprintf(stdout, "%s\n", mysql_error(con));
  if (NULL != con)
    mysql_close(con);
  mysql_library_end();
  exit(1);
}

int main(int argc, char *argv[])
{
  // MYSQL *conn_ptr;
  MYSQL *mysql_handle = NULL;
  if (mysql_library_init(0, NULL, NULL))
  {
    fprintf(stderr, "Could not initialize MySQL library.\n");
    return 1;
  }
  mysql_handle = mysql_init(mysql_handle);
  if (NULL == mysql_handle)
  {
    fprintf(stderr, "%s\n", "initialize failed");
    exit(1);
  }
  if ((mysql_handle = mysql_real_connect(mysql_handle, "localhost", "root", "root", "student", 0, NULL, 0)) == NULL)
  {

    printf("aaaa\n");
    finish_with_error(mysql_handle);
  }
  printf("bbbb\n");

  return EXIT_SUCCESS;
}